<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">提交</button>
    <script>
        let btn = document.getElementById('btn');
        function send (e){
            console.log(this,'提交了',e);
        }
        btn.addEventListener('click',throttle(send,1000))

        function throttle(fn, delay) {
            let prevTime = Date.now();

            return function(){
                if (Date.now() - prevTime > delay){
                    fn.apply(this, arguments);// apply和call的区别是apply接受的是数组参数，call接受的是单个参数
                    prevTime = Date.now();
                }
            }
        }
    </script>
</body>
</html>